#include "Log.hpp"
#include "Task.hpp"
#include "ThreadPool.hpp"
#include <memory>

int main()
{
    EnableScreen();

    srand(time(nullptr));
    unique_ptr<ThreadPool<Task>> tp = make_unique<ThreadPool<Task>>(5);//c++14新特性
    tp->InitThreadPool();
    tp->Start();

    for(int i = 0;i<10;i++)
    {
        usleep(10);
        int a = rand()%10 + 1;
        int b = rand()%100 + 1;
        Task t(a,b);
        tp->EnQueue(t);
        Log(INFO, "main thread push task: %s", t.DebugToString().c_str());
        sleep(1);
    }



    tp->Stop();//把队列中的任务全部完成
    tp->Wait();

    return 0;
}